/**
 * 
 */
package org.seginfo.httpfuzzer.header.impl;

import org.seginfo.httpfuzzer.header.AttackStrategy;
import org.seginfo.httpfuzzer.header.HeaderPropertyImpl;

/**
 * @author Administrador
 *
 */
public class AcceptLanguage extends HeaderPropertyImpl {
	
	private static final String NAME = "Accept-Language";
	private static final String VALID = "en";
	//private static final String WILDCARD = "*/*";
	private static final int BAD_STRING_MIN_LENGTH = 8;
	private static final int BAD_STRING_LENGTH = 256;

	/**
	 * @param attackStrategy
	 */
	public AcceptLanguage(AttackStrategy attackStrategy) {
		super(attackStrategy);
		this.value = this.generateValue();
	}

	/**
	 * @see org.seginfo.httpfuzzer.header.HeaderPropertyImpl#getName()
	 */
	public String getName() {
		return NAME;
	}

	/**
	 * @return
	 */
	private String generateValue() {
		
		String rv = ""; //VALID;
		
		int size = (int) (Math.random() * 10) + 1;
		for (int i = 0; i < size; i++) {
			if (!rv.equals("")) {
				rv += ',';
			}
			rv += attackStrategy.getStringAttack(BAD_STRING_MIN_LENGTH, BAD_STRING_LENGTH) + '/' + attackStrategy.getStringAttack(BAD_STRING_MIN_LENGTH, BAD_STRING_LENGTH);
			if (i % 2 == 0) {
				rv += ';' + QUALITY + '=' +
				attackStrategy.getFloatAttack();
			}
		}
		
		return rv;
	}
}
